package com.zanbo.clock.exception;

import com.zanbo.clock.model.code.BaseCodeInterface;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author: zanbo
 * @description: 自定义异常类，对一些特殊情况进行处理
 * @date: 上午 11:02 2021-4-26
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class ServiceException extends RuntimeException {
    
    protected int errorCode;
    
    protected String errorMsg;
    
    protected Object o;
    
    public ServiceException(String msg) {
        super(msg);
        errorMsg = msg;
    }
    
    
    public ServiceException(BaseCodeInterface baseCodeInterface) {
        super(baseCodeInterface.getResultMsg());
        errorCode = baseCodeInterface.getResultCode();
        errorMsg = baseCodeInterface.getResultMsg();
    }
    
    public ServiceException(BaseCodeInterface baseCodeInterface, Object o) {
        super(baseCodeInterface.getResultMsg());
        errorCode = baseCodeInterface.getResultCode();
        errorMsg = baseCodeInterface.getResultMsg();
        this.o = o;
    }
    
    public ServiceException(BaseCodeInterface baseCodeInterface, String message) {
        super(baseCodeInterface.getResultMsg());
        errorCode = baseCodeInterface.getResultCode();
        errorMsg = message;
    }
    
}
